import { getNetworkInviteCodeList } from '@/api/basic'
import { ref } from 'vue'
import { SendInviteCodeRecord } from '../types'

// 发送邀请码记录服务
const useSendInviteCodeRecordsService = () => {
  // 加载状态
  const loading = ref(false)

  // 列表的条数
  const total = ref(0)

  // 记录列表
  const recordList = ref<Array<SendInviteCodeRecord>>([])

  // 获取记录列表
  const getList = async (limit: number, page: number) => {
    loading.value = true
    const res = await getNetworkInviteCodeList({ limit, page })
    total.value = Number(res.data.data.total)
    recordList.value = res.data.data.rows
    loading.value = false
    return res
  }

  return {
    total,
    loading,
    recordList,
    getList,
  }
}

export default useSendInviteCodeRecordsService
